<?php
/**
 * Created by JetBrains PhpStorm.
 * User: Grom Hellscream
 * Date: 11/2/12
 * Time: 11:33 AM
 * To change this template use File | Settings | File Templates.
 */
// No direct access to this file
defined('_JEXEC') or die('Restricted access');
$document = JFactory::getDocument();

$congtacs = $this->get('congtacs');
$pagination = $this->get('pagination');
$session = JFactory::getSession();
$phongs = $this->get('phong');
$donvis = $this->get('donvi');
?>

<div id="crumbs">
    <div style="color: #222222;font-weight: normal;margin: 0;padding: 0">
        <a href="<?php echo JRoute::_('index.php?option=com_vast&view=vast') ?>">Trang chủ</a> »
        <span>Quá trình công tác</span>
    </div>
</div>

<div id="main" class="home">
    <h3 class="title green">Tra cứu thông tin quá trình công tác của các cán bộ trong viện</h3>

    <div class="search-form">
        <div class="wide form">
            <form id="commentform" class="commentform" class="form-validate" method="post" action="index.php?option=com_vast&view=congtrinhs">
    
                <div class="row">
                    <label style="text-align: left;">Tên cán bộ</label>		
                    <input size="60" maxlength="128" name="canboTen" id="canboTen" type="text" value="<?php if ($session->get('congtacs.ten') !== NULL) echo $session->get('congtacs.ten'); ?>"/>	
                </div>
        
                <div class="row">
                    <label style="text-align: left;">Phòng</label>		
                    <select style="width: 25%;" name="congtacsPhong" id="congtacsPhong">
                    <?php if ($session->get('congtacs.phong') == -1): ?>
                        <option value="-1" selected="selected">-Tất cả các phòng-</option>
                    <?php else: ?>
                        <option value="-1">-Tất cả các phòng-</option>
                    <?php endif; ?>
                    <?php foreach ($phongs as $phong): ?>
                    <?php if ($session->get('congtacs.phong') == $phong->id): ?>
                        <option value="<?php echo $phong->id; ?>" selected="selected"><?php echo $phong->ten; ?></option>
                    <?php else: ?>
                        <option value="<?php echo $phong->id; ?>"><?php echo $phong->ten; ?></option>
                    <?php endif; ?>
                    <?php endforeach; ?>    
                    </select>
                </div>
                
                <div class="row">
                    <label style="text-align: left;">Đơn vị</label>		
                    <select style="width: 25%;" name="congtacsDonvi" id="congtacsDonvi">
                    <?php if ($session->get('congtacs.donvi') == -1): ?>
                        <option value="-1" selected="selected">-Tất cả các đơn vị-</option>
                    <?php else: ?>
                        <option value="-1">-Tất cả các đơn vị-</option>
                    <?php endif; ?>
                    <?php foreach ($donvis as $donvi): ?>
                    <?php if ($session->get('congtacs.donvi') == $donvi->id): ?>
                        <option value="<?php echo $donvi->id; ?>" selected="selected"><?php echo $donvi->ten; ?></option>
                    <?php else: ?>
                        <option value="<?php echo $donvi->id; ?>"><?php echo $donvi->ten; ?></option>
                    <?php endif; ?>
                    <?php endforeach; ?>    
                    </select>
                </div>

                <div class="row buttons">
                    <input type="hidden" name="view" value="congtacs" />
                    <input id="submit" value="Tìm kiếm" type="submit"/>	
                    <?php echo JHtml::_('form.token'); ?>
                </div>
    
            </form>
        </div>
    </div>
    
    <div>
        <table id="rounded-corner">
            <thead>
                <tr>
                    <th scope="col" class="rounded-company"><a href="#ten">Tên cán bộ</a></th>
                    <th scope="col" class="rounded-q1"><a href="#noilamviec">Nơi làm việc</a></th>
                    <th scope="col" class="rounded-q2"><a href="#theloai">Tình trạng</a></th>                                        
                    <th scope="col" class="rounded-q3"><a href="#chucdanh">Chức danh</a></th>  
                    <th scope="col" class="rounded-q4" style="width: 70px;"><a href="#chucnang">Chức năng</a></th>  
                </tr>    
    <!--            <tr>
                    <th scope="col" class="rounded-q1" width="30%"><input type="text"/></th>
                    <th scope="col" class="rounded-q1" width="15%"><input type="text"/></th>
                    <th scope="col" class="rounded-q1" width="15%"><input type="text"/></th>
                    <th scope="col" class="rounded-q1" width="20%"><input type="text"/></th>
                    <th scope="col" class="rounded-q1" width="20%"><input type="text"/></th>
                </tr>-->
            </thead>
            <tfoot>
                <tr>
                    <td colspan="4" class="rounded-foot-left">
                        <em>
                        </em>
                    </td>
                    <td class="rounded-foot-right" style="font-size: smaller;">
                    </td>
                </tr>
            </tfoot>
            <tbody>
                <?php foreach ($congtacs as $item) { ?>
                    <tr>
                        <td>
                            <a href="<?php echo JRoute::_('index.php?option=com_vast&view=chitietcanbo&id=' . $item->hosocanbo_id); ?>"><?php echo $item->hoten; ?></a>
                            </a>
                        </td>
                        <?php if ($item->phong_id != 0): ?>
                        <td>
                            <a href="<?php echo JRoute::_('index.php?option=com_vast&view=chitietphong&id=' . $item->phong_id) ?>">
                                <?php echo $item->tenphong; ?>
                            </a>
                        </td>
                        <?php elseif ($item->donvi_id != 0): ?>
                        <td>
                            <a href="<?php echo JRoute::_('index.php?option=com_vast&view=chitietdonvi&id=' . $item->donvi_id) ?>">
                                <?php echo $item->tendonvi; ?>
                            </a>
                        <?php endif; ?>
                        <td><?php echo $item->mota; ?></td>
                        <td>
                            <?php echo $item->chucdanh; ?>
                        </td>
                        <td style="text-align: center;">
                            <a href="<?php echo JRoute::_('index.php?option=com_vast&view=congtacs&layout=view&congtacid=' . $item->id); ?>">
                                <img src="<?php echo $this->baseurl . '/components/com_vast/assets/images/view.png'; ?>" />
                            </a>
                            <?php if (JFactory::getUser()->authorise('core.manage', 'com_vast')): ?>    
                            <a href="<?php echo JRoute::_('index.php?option=com_vast&view=congtac&layout=edit&congtacid=' . $item->id); ?>">
                                <img src="<?php echo $this->baseurl . '/components/com_vast/assets/images/update.png'; ?>" />                            
                            </a>
                            <?php endif; ?>
                            <?php if (JFactory::getUser()->authorise('core.manage', 'com_vast')): ?>    
                            <a onclick="return confirm('Bạn có thực sự muốn xóa quá trình công tác này ?');" href="<?php echo JRoute::_('index.php?option=com_vast&task=congtac.delete&congtacid=' . $item->id); ?>">
                                <img src="<?php echo $this->baseurl . '/components/com_vast/assets/images/delete.png'; ?>" />                            
                            </a>
                            <?php endif; ?>
                        </td>
                    </tr>
                <?php } ?>
            </tbody>
        </table>
        <div id="tnt_pagination" style="margin-top: 5px;">
        <?php
            echo $pagination->getPagesLinks();
        ?>
        </div>            
    </div>
    <div style="float: left; width: 680px; margin-top: 5px;">
        <?php
        if (isset($_SERVER['HTTP_REFERER']))
        {
            $url = htmlspecialchars($_SERVER['HTTP_REFERER']);
            echo '<a title="Quay lại" href="' . $url . '"><span style="left: 610px; position: relative;">&laquo; Quay lại</span></a>';            
        }
        ?>    
    </div>    
</div>